package com.fuhao.handler.impl;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fuhao.core.utils.SignUtil;
import com.fuhao.handler.BaseHandler;
import com.fuhao.handler.GatewayHandler;
import com.netflix.zuul.context.RequestContext;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * 参数验签
 */
@Component
@Slf4j
public class ToVerifyMapHandler extends BaseHandler implements GatewayHandler {

	@Override
	public Boolean service(RequestContext ctx, String ipAddres, HttpServletRequest request,
						   HttpServletResponse response) {
		log.info(">>>>>>>>>拦截3 参数验证<<<<<<<<<<<<<<<<<<<<<<<<");
//		Map<String, String> verifyMap = SignUtil.toVerifyMap(request.getParameterMap(), false);
//		if (!SignUtil.verify(verifyMap)) {
//			resultError(ctx, "ip:" + ipAddres + ",Sign fail");
//			return Boolean.FALSE;
//		}
		// 传递给下一个
		gatewayHandler.service(ctx, ipAddres, request, response);
		return Boolean.TRUE;
	}

}
